package cn.org.timespace.easyframe.util.sms.telecom;


import java.util.Date;

import com.huawei.insa2.util.*;

public class SendDemo {

	private static Args arg;

	private static MySMGPSMProxy myProxy = null;

	public SendDemo() {
	}

	public static void send(){
		
	}
	
	public static MySMGPSMProxy logonProxy(){
		arg = new Args();
		try {
			//arg = new Cfg(System.getProperty("user.dir")+"/src/com/student/struts/sms/telecom/arg.xml",false).getArgs("SMGPConnect");
		//115.168.94.48
		arg.set("host", "115.168.94.48");
		arg.set("port", "8891");
		arg.set("clientid", "LTSW");//LTSW  // test1
		arg.set("shared-secret", "LTSW123");//11111111   //LTSW123
		arg.set("transaction-timeout", "30");
		arg.set("heartbeat-interval", "10");
		arg.set("heartbeat-noresponseout", "5");
		arg.set("reconnect-interval", "30");
		arg.set("version", "48");
		arg.set("debug", "true");
		if(myProxy==null)
			myProxy = new MySMGPSMProxy(new DeliverMsg(),arg);
		System.out.println("�ɹ���¼---------------------------------------");
		} catch (Exception e) {
			System.out.println("��¼ʧ��-------------------------------------:");
			System.out.println(e.getLocalizedMessage());
		}
		return myProxy;
	} 
	/**
	 * 
	 */
	public static void main(String[] a) throws Exception {
		try {
			logonProxy();
			
			String stateDesc = myProxy.getConnState();
			System.out.println("stateDesc: " + stateDesc);
			System.out.println();
			String[] moblie = {"18999001753"};
			String content = "�յ�������ظ�";
			//for(int i=0;i<50;i++)
//			SendMsg.send(myProxy,moblie,content);
//			String[] mobile = {"189099001844"};
//			String content = "�����������ι��յ�������ظ��ղ��㷢��4����Ϣ�����  ����    ";
//			SendReceiveInterface inter = SendReceiveInterface.getInstance();
//			inter.Send(mobile, content);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		while(true){
			Thread.sleep(1000);
			if(myProxy==null)
				logonProxy();
		}
	}
	
	/**
	 * Ⱥ��
	 * @param String[] moblie ���Ž��պ���
	 * @param Byte[] content ��������
	 * */
	public static void send(String[] moblie, byte[] content) {
		logonProxy();
		
		SendMsg.send(myProxy,moblie,content.toString());
	}
	

	/**
	 * Ⱥ��
	 * @param String[] moblie ���Ž��պ���
	 * @param String content ��������
	 * */
	public static void send(String[] moblie, String content) {
		logonProxy();
		SendMsg.send(myProxy,moblie,content);
	}
}
